package cn.edu.ruc.cloudcomputing.book.zookeeperTest;

import java.io.IOException;
import java.util.List;

import org.apache.zookeeper.KeeperException;

/**
 * 列出所有的组成员
 * @author JunJie.Wang
 *
 */
public class ListMembers extends ZookeeperInstance {

	public void list(String groupPath) throws KeeperException, InterruptedException{
		//获取所有的子节点
		List<String> childrens = zk.getChildren(groupPath, false);
		if(childrens.isEmpty()){
			System.out.println("组"+groupPath+"中没有组成员存在！");
			System.exit(1);
		}
		
		for(String children:childrens){
			System.out.println("组成员："+children);
		}
	}
	
	public static void main(String[] args) throws IOException, KeeperException, InterruptedException{
		ListMembers lm = new ListMembers();
		lm.createZKInstance();
		lm.list("/ZKGroup08030002");
	}
}
